import type { GoodsItemListModel, GoodsItemModel } from "./goods";
import type { userGetuserInfoReturnModel } from "./user";
import type { AddressItem } from "./address";

import http from "@/api";

interface MyOrderGetListSendModel {
	page: number;
	size: number;
	orderStatus?: string;
}

export interface MyOrderItem {
	id: number;
	orderId: string;
	userId: number;
	goodsId: number;
	adminId: number;
	none_sku: boolean;
	orderStatus: string;
	descText: null | string;
	addressId: number;
	createTime: number;
	updateTime: number;
	goods: GoodsItemModel;
	user: userGetuserInfoReturnModel;
	address: AddressItem;
	list: GoodsItemListModel[];
	cart_num?: number; // 订单选择的商品数量选填
}

interface MyOrderGetListReturnModel {
	total: number;
	pageNum: number;
	page: number;
	size: number;
	list: MyOrderItem[];
}
/**
 * 根据状态获取我的订单列表
 */
export function myOrderGetList(params: MyOrderGetListSendModel) {
	return http.get<MyOrderGetListReturnModel>("/myOrder/getList", params);
}

export enum OrderStatus {
	DFK = "DFK",
	DFH = "DFH",
	DSH = "DSH",
	DPJ = "DPJ",
	YQX = "YQX",
	YWC = "YWC"
}

export interface MyOrderSetDFHSendModel {
	id: number;
	orderStatus: OrderStatus;
}
/** 改变代发货商品状态（模拟发货） */
export function myOrderSetDFH(data: MyOrderSetDFHSendModel) {
	return http.post("/myOrder/setDFH", data);
}
